﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XYZshell.Game.CardGameEngine
{
	public  class While:RegionActivity
	{

		public While() : base()
		{
		}

		public override void Start()
		{
			WhileActivityEventArgs e=new WhileActivityEventArgs();
			e.Body = this.Body;
			e.Condition = this.Condition;
			OnStarted( new EventArgs() );
			VariableCollection vars=new VariableCollection( this.Variables );
			while (Condition.Result())
			{
				Body.Variables = vars;
				Body.Start();
			}
			OnFinished( new EventArgs() );
		}

		public  IActivity Body
		{
			get;
			set;
		}

		public  ICondition Condition
		{
			get;
			set;
		}
	}

	public class WhileActivityEventArgs : FlowEventArgs
	{
		public  IActivity Body
		{
			get;
			set;
		}

		public  ICondition Condition
		{
			get;
			set;
		}
	}
}
